﻿//#define _CRT_SECURE_NO_WARNINGS  1
////一定要动手，例子不管多么简单，建议至少自己手敲一遍看看是否理解了里头的细枝末节。
////一定要学会思考，思考为什么要这样，而不是那样。还要举一反三地思考
//#include<iostream>
//#include<string>
//#include<vector>
//using namespace std;
////void func(const string str)
////{
////	cout << "函数" << endl;
////	//string::const_reverse_iterator it = str.rbegin();
////	auto it = str.rbegin();
////	while (it != str.rend())
////	{
////		cout << *it << " ";
////		it++;
////	}
////	cout << endl;
////
////	auto vit = str.crbegin();
////	while (vit != str.crend())
////	{
////		cout << *vit <<" ";
////		vit++;
////	}
////	cout << endl;
////}
////void func2()
////{
////	//reserve  //保留
////	//try {
////	//
////	//	size_t max = str.max_size();
////	//	//str.reserve(max);
////	//	size_t real = str.capacity();
////	//	cout << "最大容量::" << max << endl;
////	//	cout << "实际容量::" << real << endl;
////	//}
////	/*catch (exception e)
////	{
////		cout << e.what() << endl;
////	}*/
////	try {
////		string str("hello world!");
////		size_t size = str.capacity();
////		cout << size << endl;
////		for (int i = 0; i < 100; i++)
////		{
////			str.push_back(i);
////			if (str.capacity() != size)
////			{
////				cout << str.capacity() << endl;
////				size = str.capacity();
////			}
////		}
////	}
////	catch (exception e)
////	{
////		cout << e.what() << endl;
////	}
////	
////}
////int main()
////{
////	/*string str("hello world!");
////	string::reverse_iterator it = str.rbegin();
////	while (it != str.rend())
////	{
////		cout << *it <<" ";
////		it++;
////	}
////	cout << endl;
////	func(str);*/
////	func2();
////	system("pause");
////	return 0;
////}
//int main()
//{
//	/*string str;
//	size_t num = str.capacity();
//	str.reserve(10);
//	size_t num1 = str.capacity();
//	cout << num << "    " << num1 << endl;
//	string str1("1111111122222223333333");
//	size_t num2 = str1.capacity();
//	cout << num2 << endl;
//	str1.reserve(10);*/
//	/*size_t num3 = str1.capacity();
//	cout << num3 << endl;*/
//	//string str4("hello world!");
//	//cout<<str4.capacity()<<endl;
//	//cout << str4.size()<<endl;
//	//str4.resize(100,'x');
//	//cout << str4.capacity() << endl;
//	//cout << str4.size() << endl;
//	//cout << str4 << endl;
//	////现象resize可以扩容，可以尾差数据
//
//	//str4.resize(13);
//	//cout << str4.capacity() << endl;
//	//cout << str4.size() << endl;
//	////现象：resize 不能缩容，可以删除数据
//
//
//
//
//	//str4.resize(3);
//	//cout << str4.capacity() << endl;
//	//cout << str4.size() << endl;
//	//cout << str4 << endl;
//	//现象：数据删除，空间没有改变
//	
//	//[] 与 at有什么区别？
//	try {
//		string str("hello world!");
//		//cout << str[13] << endl;  //直接报错
//	cout << str.at(13) << endl;//温柔方式：抛异常
//	}
//	catch (exception e)
//	{
//		cout << e.what() << endl;
//	}
//	//append
//	string str("hello world!");
//	str.push_back(' ');
//	str.append("x");
//	cout << str << endl;
//
//	string str1("hello world!");
//	const string str2("xxxxxxxxx");
//	cout << str2 << endl;
//
//	cout << "改变前" << endl;
//	str1.append(++str2.begin(), --str2.end());
//	cout << str1 << endl;
//	
//
//
//
//
//
//
//
//	system("pause");
//	return 0;
//}